package org.opensourcedea.ui.osdeagui;

import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.swt.SWT;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.actions.ActionFactory;
import org.eclipse.ui.actions.ActionFactory.IWorkbenchAction;
import org.eclipse.ui.application.ActionBarAdvisor;
import org.eclipse.ui.application.IActionBarConfigurer;

public class ApplicationActionBarAdvisor extends ActionBarAdvisor {
	
	private IWorkbenchAction exitAction;
	private IWorkbenchAction aboutAction;
	private IWorkbenchAction preferencesAction;
	private SaveAsDEAProblemAction saveAsDEAPAction;
	private OpenDEAProblemAction openDEAPAction;
	private SaveDEAProblemAction saveDEAProblemAction;
	
	

    public ApplicationActionBarAdvisor(IActionBarConfigurer configurer) {
        super(configurer);
    }

    protected void makeActions(IWorkbenchWindow window) {
    	
    	exitAction = ActionFactory.QUIT.create(window); //the ActionFactory defines a set of common actions and can be used in the application.  
    	register(exitAction);  //register the action so they are deleted when the Workbench window is closed  
    	
    	aboutAction = ActionFactory.ABOUT.create(window);
    	register(aboutAction);
    	
    	preferencesAction = ActionFactory.PREFERENCES.create(window);
    	register(preferencesAction);
    	
    	
    	
    	openDEAPAction = new OpenDEAProblemAction();
    	openDEAPAction.setText("Open a DEA Problem...");
    	openDEAPAction.setToolTipText("Open a DEA Problem file");
    	openDEAPAction.setAccelerator(SWT.ALT + 'O');
    	register(openDEAPAction);
    	
    	saveAsDEAPAction = new SaveAsDEAProblemAction();
    	saveAsDEAPAction.setText("Save As...");
    	saveAsDEAPAction.setToolTipText("Saves the DEA Problem as...");
    	saveAsDEAPAction.setAccelerator(SWT.ALT + SWT.SHIFT + 'S');
    	register(saveAsDEAPAction);
    	
    	saveDEAProblemAction = new SaveDEAProblemAction();
    	saveDEAProblemAction.setText("Save");
    	saveDEAProblemAction.setToolTipText("Saves the current DEAProblem");
    	saveDEAProblemAction.setAccelerator(SWT.ALT + 'S');
    	register(saveDEAProblemAction);
    	
    }

    protected void fillMenuBar(IMenuManager menuBar) {
    	
    	MenuManager fileMenu = new MenuManager("&File", "file"); //create a menuManager to take care of all submenus in "File"  
    	MenuManager windowMenu = new MenuManager("&Window", "window");
    	MenuManager helpMenu = new MenuManager("&Help", "help");
    	
    	
//    	MenuManager expandingMenu = new MenuManager("&Expand", "expand");  
    	windowMenu.add(preferencesAction); //Add the "preferences" action  
    	helpMenu.add(aboutAction); //Add the "about" action  
//    	expandingMenu.add(new Separator()); //Add a horizontal separator  uyjh
    	
    	fileMenu.add(openDEAPAction);
    	fileMenu.add(saveDEAProblemAction);
    	fileMenu.add(saveAsDEAPAction);
//    	fileMenu.add(expandingMenu); //Add the "exit" action  	
    	fileMenu.add(exitAction); //Add the "exit" action  
    	
    	menuBar.add(fileMenu);//Add the "File" menu to the menuBar  
    	menuBar.add(windowMenu);
    	menuBar.add(helpMenu);
    }
    
}
